home *** CD-ROM | disk | FTP | other *** search
/ Alpha CD-ROM Bonus Pack / Alpha CD-ROM Bonus Pack.iso / life / shared.dir / 00494_ButtonHandlers.ls < prev    next >
Encoding:
Text File  |  1995-01-16  |  4.1 KB  |  135 lines

  1. on setHandCursor spriteList
  2.   set hand1 to the number of cast "HandCursorA"
  3.   set hand2 to the number of cast "HandCursorB"
  4.   set handCursor to [hand1, hand2]
  5.   repeat with i = 1 to count(spriteList)
  6.     set the cursor of sprite getAt(spriteList, i) to handCursor
  7.   end repeat
  8. end
  9.  
  10. on resetSpriteCursor first, last
  11.   repeat with i = first to last
  12.     set the cursor of sprite i to -1
  13.   end repeat
  14. end
  15.  
  16. on buttonClicked buttonList, buttonSymbol, finalPuppetState
  17.   set spriteNum to getaProp(buttonList, buttonSymbol)
  18.   if the clickOn <> spriteNum then
  19.     return 0
  20.   else
  21.     set castUp to string(buttonSymbol) & "_B1"
  22.     set castDown to string(buttonSymbol) & "_B2"
  23.     puppetSprite(spriteNum, 1)
  24.     set the castNum of sprite spriteNum to the number of cast castDown
  25.     updateStage()
  26.     set rolledOver to 1
  27.     repeat while the stillDown
  28.       if rollOver(spriteNum) and (rolledOver = 0) and the stillDown then
  29.         set the castNum of sprite spriteNum to the number of cast castDown
  30.         set rolledOver to 1
  31.         updateStage()
  32.       end if
  33.       if (rollOver(spriteNum) = 0) and (rolledOver = 1) then
  34.         set the castNum of sprite spriteNum to the number of cast castUp
  35.         set rolledOver to 0
  36.         updateStage()
  37.       end if
  38.     end repeat
  39.     if rolledOver then
  40.       makeButtonClickSound()
  41.     end if
  42.     set the castNum of sprite spriteNum to the number of cast castUp
  43.     updateStage()
  44.     if voidp(finalPuppetState) then
  45.       puppetSprite(spriteNum, 0)
  46.     else
  47.       puppetSprite(spriteNum, finalPuppetState)
  48.     end if
  49.     return rolledOver
  50.   end if
  51. end
  52.  
  53. on buttonPushed buttonList, buttonSymbol
  54.   global gButtonClickSound
  55.   set spriteNum to getaProp(buttonList, buttonSymbol)
  56.   if the clickOn <> spriteNum then
  57.     return 0
  58.   else
  59.     set castUp to string(buttonSymbol) & "_B1"
  60.     set castDown to string(buttonSymbol) & "_B2"
  61.     puppetSprite(spriteNum, 1)
  62.     set the castNum of sprite spriteNum to the number of cast castDown
  63.     updateStage()
  64.     set rolledOver to 1
  65.     repeat while the stillDown
  66.       if rollOver(spriteNum) and (rolledOver = 0) and the stillDown then
  67.         set the castNum of sprite spriteNum to the number of cast castDown
  68.         set rolledOver to 1
  69.         updateStage()
  70.       end if
  71.       if (rollOver(spriteNum) = 0) and (rolledOver = 1) and the stillDown then
  72.         set the castNum of sprite spriteNum to the number of cast castUp
  73.         set rolledOver to 0
  74.         updateStage()
  75.       end if
  76.     end repeat
  77.     if rolledOver then
  78.       makeButtonClickSound()
  79.     end if
  80.     puppetSprite(spriteNum, 0)
  81.     updateStage()
  82.     return rolledOver
  83.   end if
  84. end
  85.  
  86. on checkBoxClick currentState, spriteNum, castZero, castOne, puppetState
  87.   puppetSprite(spriteNum, 1)
  88.   set newState to not currentState
  89.   if currentState = 0 then
  90.     set overCast to the number of cast castOne
  91.     set notOverCast to the number of cast castZero
  92.   else
  93.     set overCast to the number of cast castZero
  94.     set notOverCast to the number of cast castOne
  95.   end if
  96.   set the castNum of sprite spriteNum to overCast
  97.   updateStage()
  98.   set rolledOver to 1
  99.   repeat while the stillDown
  100.     if rollOver(spriteNum) and (rolledOver = 0) and the stillDown then
  101.       set the castNum of sprite spriteNum to overCast
  102.       set rolledOver to 1
  103.       set newState to not currentState
  104.       updateStage()
  105.     end if
  106.     if (rollOver(spriteNum) = 0) and (rolledOver = 1) and the stillDown then
  107.       set the castNum of sprite spriteNum to notOverCast
  108.       set rolledOver to 0
  109.       set newState to currentState
  110.       updateStage()
  111.     end if
  112.   end repeat
  113.   if puppetState = 0 then
  114.     puppetSprite(spriteNum, 0)
  115.   end if
  116.   return newState
  117. end
  118.  
  119. on rollOverHilite buttonList, buttonSymbol
  120.   set spriteNum to getaProp(buttonList, buttonSymbol)
  121.   if rollOver(spriteNum) then
  122.     set castDown to string(buttonSymbol) & "_B2"
  123.     puppetSprite(spriteNum, 1)
  124.     set the castNum of sprite spriteNum to the number of cast castDown
  125.     updateStage()
  126.     return 1
  127.   else
  128.     set castUp to string(buttonSymbol) & "_B1"
  129.     puppetSprite(spriteNum, 1)
  130.     set the castNum of sprite spriteNum to the number of cast castUp
  131.     updateStage()
  132.     return 0
  133.   end if
  134. end
  135.